<style>
.equipmentDownTime span.error {
    position: absolute !important;
    left: 260px;
}
</style>
<div class="pageContent">
    <form method="post" action="${rc.getContextPath()}/manage/equipmentDownTime/saveEquipmentDownTime" class="pageForm required-validate" onsubmit="return tsubmit(this);">
        <div class="pageFormContent" <#if pattern=="modify">layoutH="130"<#else>layoutH="100"</#if> >
            <input type="hidden" name="navTabId" value="${navTabId!''}"> <input type="hidden" name="id" value="<#if (equipmentDownTime.id)??>${equipmentDownTime.id!''}</#if>">
            <fieldset>
                <dl>
                    <dt><@label key="equipmentCode.C,colon">设备编号：</@label></dt>
                    <#if pattern!="modify">
                    <dd  class="equipmentDownTime">
                        <input class="required look" id="equipmentLookup.equipmentCode" name="equipmentCode" type="text" postField="equipmentCode" 
                        suggestFields="equipmentCode,equipmentText" suggestUrl="${rc.getContextPath()}/manage/equipment/equipmentSuggest" 
                        value="<#if (equipmentDownTime.equipmentCode)??>${equipmentDownTime.equipmentCode!''}</#if>" lookupGroup="equipmentLookup" 
                        warn="<@label key='equipmentCode.C,doesNotExist.C'>设备编号不存在</@label>" 
                        remote="${rc.getContextPath()}/manage/equipment/validateEquipmentCodeForSelect" /> 
                        <a class="btnLook" href="${rc.getContextPath()}/manage/equipment/equipmentLookUp" rel="equipmentLookup_dialog" width="700" height="450" lookupGroup="equipmentLookup"></a>
                    </dd>
                    <#else>
                    <dd  class="equipmentDownTime">
                        <input class="required" id="equipmentLookup.equipmentCode" name="equipmentCode" type="text" postField="equipmentCode" 
                        value="<#if (equipmentDownTime.equipmentCode)??>${equipmentDownTime.equipmentCode!''}</#if>" readonly="readonly"
                    </dd>
                    </#if>
                </dl>
                <dl>
                    <dt><@label key='equipmentText.C,colon'>设备描述：</@label></dt>
                    <dd>
                        <input id="equipmentLookup.equipmentText" value="<#if (equipmentDownTime.equipmentText)??>${equipmentDownTime.equipmentText!''}</#if>"  readonly size="22" type="text" maxlength="60" name="equipmentText" />
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="shutDownCauseCode.C,colon">停机原因代码：</@label></dt>
                    <dd class="equipmentDownTime">
                        <input class="required look" id="shutDownCauseLookup.shutDownCauseCode" name="shutDownCauseCode" value="${equipmentDownTime.shutDownCauseCode!''}" 
                              size="22" type="text" maxlength="20" class="required  alphanumeric toUp" postField="shutDownCauseCode"  suggestFields="shutDownCauseCode,shutDownCauseText"
                              suggestUrl="${rc.getContextPath()}/manage/shutDownCause/shutDownCauseSuggest"  
                              warn="<@label key='shutDownCauseCode.C,doesNotExist.C'>停机原因编号不存在</@label>" remote="${rc.getContextPath()}/manage/shutDownCause/checkShutDownCauseCode" />
                        <a class="btnLook" href="${rc.getContextPath()}/manage/shutDownCause/shutDownCauseLookup" rel="shutDownCause_dialog" width="700" height="450" lookupGroup="shutDownCauseLookup"></a>
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="shutDownCauseText.C,colon">停机原因描述：</@label></dt>
                    <dd>
                        <input name="shutDownCauseText" id="shutDownCauseLookup.shutDownCauseText"
                            value="${equipmentDownTime.shutDownCauseText!''}" size="22" type="text" maxlength="60" class="required"  readonly="readonly"
                          />
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="theDate.C,colon">作业日期：</@label></dt>
                    <dd class="equipmentDownTime">
                        <input type="text" id="jobDate" class="required date" readonly="readonly" name="theDate" dateFmt="yyyy-MM-dd" value="${(equipmentDownTime.theDate?string('yyyy-MM-dd'))?if_exists}"/> <a class="inputDateButton" href="javascript:;"><@label key="select.B">选择</@label></a>
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="shutDownDateTime.C,colon">停机时间：</@label></dt>
                    <dd class="equipmentDownTime">
                        <input id="startDateTime" type="text" class="required date"  name="startDateTime" dateFmt="yyyy-MM-dd HH:mm" value="${(equipmentDownTime.startDateTime?string('yyyy-MM-dd HH:mm'))?if_exists}"/> <a class="inputDateButton" href="javascript:;"><@label key="select.B">选择</@label></a>
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="downTime.C,colon">停机时长：</@label></dt>
                    <dd class="equipmentDownTime">
                        <input type="text" min="0" max="1440" id="ss" class="required oneDecimal" name="downTime"  maxlength="10" value="<#if (equipmentDownTime.downTime)??>${equipmentDownTime.downTime!''}</#if>"/>
                    </dd>
                </dl>
                <dl style="width:600px;height:90px;">
                    <dt><@label key='memo.C,colon'>备注：</@label></dt>
                    <dd>
                    <textarea style="width:435px;" name="memo"  maxlength="200" value="${equipmentDownTime.memo!''}" rows="4"><#if (equipmentDownTime.memo)??>${equipmentDownTime.memo!''}</#if></textarea>
                    </dd>
                </dl>
            </fieldset>
        </div>
        <#if (equipmentDownTime.id)??> <#assign createInfo=equipmentDownTime/> <#include "/common/createInfo.html"> </#if>
        <div class="formBar">
            <ul>
                <li><div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit"><@label key="save.B">保存</@label></button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="buttonActiveGrey">
                        <div class="buttonContent">
                            <button type="button" class="close"><@label key="cancel.B">取消</@label></button>
                        </div>
                    </div></li>
            </ul>
        </div>
    </form>
</div>

<script type="text/javascript">


function checkTime()
{
    var downDay=$("#startDateTime",$.pdialog.getCurrent()).val();
    var jobDay=$("#jobDate",$.pdialog.getCurrent()).val();
    if(jobDay.length!=0&&downDay.length!=0)
    {
        var downDate = new Date(Date.parse(downDay.replace(/-/g, '/ ')));
        var jobDate= new Date(Date.parse(jobDay.replace(/-/g, '/ ')));
        var d=downDate-jobDate;
        var diff = Date.parse(downDay); 
        var twoDay=48*60*60*1000;
        if(d<0||d>twoDay)
        {
            alertMsg.warn('<@label key="downTimeError.M">停机时间只可在作业日期的当天或第二天！</@label>');
            return false;
        }
        else
        {
            return true;
        }
    }
}

function tsubmit(t)
{
    if(!checkTime())
    {
        return false;
    }
    return validateCallback(t, dialogAjaxDone);
}

</script>